com.rscja.team.mtk.deviceapi

## Class Infrared_mtk

- java.lang.Object
- - com.rscja.team.mtk.deviceapi.Infrared_mtk

- All Implemented Interfaces:
    IInfrared

      public class Infrared_mtk
      extends java.lang.Object
      implements IInfrared

  红外模块操作类 Infared module operation type
  Author:
    liuruifeng

- - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `close()` 关闭红外模块 Switch off infared module
    `void` | `closeLED()` 关闭辅助灯 Close LED
    `java.lang.String` | `getIDAndPowerWithWattmeter()` 获取电表ID和电能值,97标准 Acquire powermeter ID and energy value, 97 standard
    `java.lang.String` | `getIDAndPowerWithWattmeter(int protocol)` 获取电表ID和电能值 Acquire powermeter ID and energy value
    `static Infrared_mtk` | `getInstance()`
    `boolean` | `isPowerOn()` 判断设备是否上电 Judge the device is powered on or not.
    `boolean` | `open()` 打开红外模块,默认1200波特率 Switch on infared module, default 1200 baud rate
    `boolean` | `open(int baudrate)` 打开红外模块 Switch on infared module
    `boolean` | `open(int baudrate, int check)` 打开红外模块 Switch on infared module
    `boolean` | `open(int baudrate, int dataBits, int stopBits, int check)` 打开红外模块 Switch on infared module
    `void` | `openLED()` 打开辅助灯 Open LED
    `byte[]` | `receive()` 接收数据 Receive data
    `boolean` | `send(byte[] data)` 发送数据 send Data
    `boolean` | `switchBaudrate(int baudrate, int dataBits, int stopBits, int check)` 切换波特率

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

    - ### Methods inherited from interface com.rscja.deviceapi.interfaces.IInfrared

      `isPowerOn`

- - ### Method Detail

    - #### getInstance

          public static Infrared_mtk getInstance()
                                          throws ConfigurationException

      Returns:
        红外模块操作实例
        infared module operation Instance
      Throws:
        `ConfigurationException` - 配置错误异常
        Configuration error

    - #### open

          public boolean open()

      打开红外模块,默认1200波特率
      Switch on infared module, default 1200 baud rate
      Specified by:
        `open` in interface `IInfrared`
      Returns:
        true成功，false失败

    - #### open

          public boolean open(int baudrate)

      打开红外模块
      Switch on infared module
      Specified by:
        `open` in interface `IInfrared`
      Parameters:
        `baudrate` - 波特率，如：1200、4800、2400
        baud rate, e.g.: 1200, 4800, 2400
      Returns:
        true成功，false失败

    - #### open

          public boolean open(int baudrate,
                              int check)

      打开红外模块
      Switch on infared module
      Specified by:
        `open` in interface `IInfrared`
      Parameters:
        `baudrate` - 波特率，如：1200、4800、2400
        baud rate, e.g.: 1200, 4800, 2400
        `check` - 0,不校验;1,奇校验;2,偶校验
        0, no verification;1, odd verification, even verification
      Returns:
        true成功，false失败

    - #### open

          public boolean open(int baudrate,
                              int dataBits,
                              int stopBits,
                              int check)

      打开红外模块
      Switch on infared module
      Specified by:
        `open` in interface `IInfrared`
      Parameters:
        `baudrate` - 波特率，如：1200、4800、2400
        baud rate, e.g.: 1200, 4800, 2400
        `dataBits` - 数据位 取值为 7 或者8
        `stopBits` - 停止位 取值为 1 或者2
        `check` - 校验位 0,不校验;1,奇校验;2,偶校验
        0, no verification;1, odd verification, even verification
      Returns:
        true成功，false失败

    - #### switchBaudrate

          public boolean switchBaudrate(int baudrate,
                                        int dataBits,
                                        int stopBits,
                                        int check)

      切换波特率
      Specified by:
        `switchBaudrate` in interface `IInfrared`
      Parameters:
        `baudrate` - 波特率
        `dataBits` - 数据位
        `stopBits` - 停止位
        `check` - 校验位
      Returns:
        true成功，false失败

    - #### close

          public boolean close()

      关闭红外模块
      Switch off infared module
      Specified by:
        `close` in interface `IInfrared`
      Returns:
        true成功，false失败

    - #### send

          public boolean send(byte[] data)

      发送数据
      send Data
      Specified by:
        `send` in interface `IInfrared`
      Parameters:
        `data` - 数据
        Data
      Returns:
        true成功，false失败

    - #### receive

          public byte[] receive()

      接收数据
      Receive data
      Specified by:
        `receive` in interface `IInfrared`
      Returns:
        数据
        data

    - #### getIDAndPowerWithWattmeter

          public java.lang.String getIDAndPowerWithWattmeter()

      获取电表ID和电能值,97标准
      Acquire powermeter ID and energy value, 97 standard
      Specified by:
        `getIDAndPowerWithWattmeter` in interface `IInfrared`
      Returns:
        电表ID和电能值以“:”分割，返回null表示失败
        powermeter ID and energy value should be divided by ':', return null means failure

    - #### getIDAndPowerWithWattmeter

          public java.lang.String getIDAndPowerWithWattmeter(int protocol)

      获取电表ID和电能值
      Acquire powermeter ID and energy value
      Specified by:
        `getIDAndPowerWithWattmeter` in interface `IInfrared`
      Parameters:
        `protocol` - 97,DL/T 645—1997标准;07,DL/T 645—2007标准
        `protocol` - 97, DL/T 645-1997 standard;07,DL/T 645-2007 standard
      Returns:

    - #### openLED

          public void openLED()

      打开辅助灯
      Open LED
      Specified by:
        `openLED` in interface `IInfrared`

    - #### closeLED

          public void closeLED()

      关闭辅助灯
      Close LED
      Specified by:
        `closeLED` in interface `IInfrared`

    - #### isPowerOn

          public boolean isPowerOn()

      判断设备是否上电
      Judge the device is powered on or not.
      Returns: